@extends( 'layouts.main' )

@section( 'title', '编辑账单' )

@section( 'content' )
<div class="weui-toptips weui-toptips_warn js_tooltips" style="display: none;"></div>
<form>

    <div class="weui-cells__title">选择一个用户进行绑定</div>

    <div class="weui-cells weui-cells_radio">
    @foreach ( $userList as $uid => $name )
        <label class="weui-cell weui-check__label">
            <div class="weui-cell__bd">
                <p>{{ $name }}</p>
            </div>
            <div class="weui-cell__ft">
                <input type="radio" class="weui-check" name="uid" value="{{ $uid }}">
                <span class="weui-icon-checked"></span>
            </div>
        </label>
    @endforeach
    </div>

    <input type="hidden" name="openid" value="{{ isset( $openid ) ? $openid : '' }}">

    <div class="weui-btn-area">
        <a class="weui-btn weui-btn_primary" href="javascript:" id="submit-button">绑 定</a>
    </div>

    {{ csrf_field() }}

</form>
<script type="text/javascript">
$('#submit-button').click(function(){
    $.ajax({
        url: '/binding',
        type: 'post',
        dataType: 'json',
        data: $('form').serialize(),
        success: function( res ) {
            if ( res.errcode != 0 )
                $('.weui-toptips').html(res.msg).fadeIn(400).delay(3000).fadeOut(400);
            else
                window.location.href = '/';
        }
    })
})
</script>
@stop